//
//  HomeViewHead.m
//  test
//
//  Created by 朱圳 on 2017/12/27.
//  Copyright © 2017年 朱圳. All rights reserved.
//

#import "HomeViewHead.h"

@implementation HomeViewHead

-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        [self createUI];
    }
    return self;
}

-(void)createUI{
    
    UIImageView *bg = [[UIImageView alloc]init];
    bg.image = [UIImage imageNamed:@"stu-bg"];
    [self addSubview:bg];
    [bg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self);
        make.top.mas_equalTo(self);
        make.size.mas_equalTo(CGSizeMake(ScreenWidth, 50));
    }];
    
    UILabel  *studaylab = [[UILabel alloc]init];
    studaylab.text = @"学习天数:";
    [bg addSubview:studaylab];
    [studaylab mas_makeConstraints:^(MASConstraintMaker *make) {
        [make.left.mas_equalTo(bg.mas_left) setOffset:10];
        make.centerY.mas_equalTo(bg);
    }];
    self.studaylab = studaylab;
    UILabel  *falldaylab = [[UILabel alloc]init];
    falldaylab.text = @"考研倒计时:";
    [bg addSubview:falldaylab];
    [falldaylab mas_makeConstraints:^(MASConstraintMaker *make) {
        
       [make.right.mas_equalTo(bg.mas_right) setOffset:-10];
        make.centerY.mas_equalTo(bg);
    }];
    self.falldaylab = falldaylab;
    UILabel  *jxlab = [[UILabel alloc]init];
    jxlab.text = @"今日计划";
    self.StudyPlan=jxlab;
    [self addSubview:jxlab];
    [jxlab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(self);
        [make.top.mas_equalTo(bg.mas_bottom) setOffset:10];
    }];

    
}
-(void)setModel:(PlanModel *)model{
    _model = model;
    self.studaylab.text = [NSString stringWithFormat:@"学习天数:%@天",_model.days];
    if(_model.countdown==nil){
    self.falldaylab.text=[NSString stringWithFormat:@"考研倒计时:%@天",CountDowns];
    }else{
         self.falldaylab.text = [NSString stringWithFormat:@"考研倒计时:%@天",_model.countdown];
    }
   
    self.StudyPlan.text=[NSString stringWithFormat:@"第%@天学习计划",_model.days];
}
@end
